#pragma once
#include "windows.h"
#include "d3d9.h"
#include "d3dx9.h"
#include "atltime.h"
#include "dinput.h"


#include "TraceEvent.h"
#include "DXManager.h"
#include "FrameWorkGlobal.h"
#include "CTimeControl.h"
using namespace std;

static TCHAR szAppName[]="UIT TeTris 3D";
class IGameApp
{
private :
	int m_pFPS;
	bool m_pIsFullScreen;
	int m_pScreenWidth;
	int m_pScreenHeight;
	int m_pMode;
	BYTE m_pKeys[256];
	DIDEVICEOBJECTDATA m_pKeyEvent[KEYBOARD_BUFFER_SIZE];
	
	DWORD m_Time_start;
	DWORD m_DeltaTime; 
	
protected:
	HWND m_hWnd;
	HINSTANCE m_hInstance;

	DXManager *m_DxManager;
	CTimeControl m_Timer;

public:		
	IGameApp(HINSTANCE,int _Mode,bool _Full,int _frameRate);
	
	bool InitWindow();
	void SetScreenDimension();
	void KeyBoardProcessing();
	int IsKeyDown(int KeyCode);
	int  Init();
	void Run();
	void Destroy();

	
	virtual void Update();
	virtual void Render();
	virtual void OnKeyDown(int KeyCode);
	virtual void OnKeyUp(int KeyCode);
	virtual void InputDownProcessing(int Delta){};
	virtual void InputUpProcessing(){};
	virtual void LoadResource(){};

	static LRESULT CALLBACK WndProc(HWND,UINT,WPARAM,LPARAM);

	
public:// encapsulation variable
	LPDIRECT3DDEVICE9 getD3DDevice()
	{
		return m_DxManager->GetD3DDDevice();
	}
};
